import 'package:flutter/material.dart';

class PageViewDemo extends StatelessWidget {
  const PageViewDemo({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('PageViewDemo'),
        elevation: 0.0,
      ),
      body: PageView(
        // pageSnapping: false,
        // reverse: true,
        // scrollDirection: Axis.horizontal,
        scrollDirection: Axis.vertical,
        onPageChanged: (currentpage) {
          print(currentpage);
        },
        controller: PageController(
          initialPage: 1,
          keepPage: true,
          // viewportFraction: 0.85,
        ),
        children: <Widget>[
          Container(
            color: Colors.green,
            alignment: Alignment.center,
            child: Text(
              'One',
              style: TextStyle(fontSize: 32.0, color: Colors.white),
            ),
          ),
          Container(
            color: Colors.blue,
            alignment: Alignment.center,
            child: Text(
              'Two',
              style: TextStyle(fontSize: 32.0, color: Colors.white),
            ),
          ),
          Container(
            color: Colors.blueGrey,
            alignment: Alignment.center,
            child: Text(
              'Three',
              style: TextStyle(fontSize: 32.0, color: Colors.white),
            ),
          ),
          Container(
            color: Colors.pink,
            alignment: Alignment.center,
            child: Text(
              'Four',
              style: TextStyle(fontSize: 32.0, color: Colors.white),
            ),
          ),
        ],
      ),
    );
  }
}
